package com.twu.biblioteca.Helper;

import com.twu.biblioteca.Models.*;
import com.twu.biblioteca.System.Library;
import com.twu.biblioteca.System.BibliotecaSystem;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created by ubuntu on 4/29/14.
 */
public class Utility {

    public String convertListToString(ArrayList<?> items, String delimiter) {
        StringBuilder stringBuilder = new StringBuilder();
        Iterator<?> iterator = items.iterator();
        while (iterator.hasNext()) {
            Object currenItem = iterator.next();
            stringBuilder.append(currenItem);
            if(iterator.hasNext()) {
                stringBuilder.append(delimiter);
            }
        }
        return stringBuilder.toString();
    }


    public static void main(String[] args) {
        Data data = new Data();
        User user = new User("default","nothing");
        user.setId("12-345");
        data.addUser(user);
        Library library = new Library(data);
        library.addItem(new Book("Agile"),Book.class);
        library.addItem(new Book("TW"),Book.class);
        library.addItem(new Book("Test"),Book.class);
        library.addItem(new Movie("Movie1"),Movie.class);
        library.addItem(new Movie("SH"),Movie.class);
        library.addItem(new Movie("2 states"),Movie.class);


        BibliotecaSystem bibliotecaSystem = new BibliotecaSystem(data,library);
        bibliotecaSystem.addMenu(new Menu("Checkout Book","CB"));
        bibliotecaSystem.addMenu(new Menu("Checkout Movie","CM"));
        bibliotecaSystem.addMenu(new Menu("List Movies","LM"));
        bibliotecaSystem.addMenu(new Menu("List Books","LB"));
        bibliotecaSystem.addMenu(new Menu("Return Book","RB"));
        bibliotecaSystem.addMenu(new Menu("Return Movie","RM"));
        bibliotecaSystem.addMenu(new Menu("Quit","Q"));
        bibliotecaSystem.startSystem();

    }
}

